/**
 * 
 */
axios.defaults.withCredentials = true;

const mainVue = new Vue({
	el: '#app',
	data: {
		id: '',
		count: 0,
		username: '',
		password: '',
		userisLogin: '',
		hrisLogin: '',
		activeName: 'first',
		dialogForm2Visible: false,
		dialogForm1Visible: false,
		nextWant: 1,
		number: 9,
		nextWant2: 1,
		number2: 9,
		input1: "",
		select: '职位',
		count: 1,
		student: {
			srollno: "22222",
			sname: "哈哈哈哈",
			spassword: "123",
			sgender: "女",
			sbatch: "18j03"
		},
		jobList: [],
		jobListBytime: [],
		bid: 1,
		blockList: [
			{
				icon1: 'static/img/background/icon1.png',
				background: 'static/img/background/advertisingbg_01.png',
				text: "年度招聘专区"
			},
			{
				icon1: 'static/img/background/icon2.png',
				background: 'static/img/background/advertisingbg_02.png',
				text: "秋招盛典，每日内推"
			},
			{
				icon1: 'static/img/background/icon3.png',
				background: 'static/img/background/advertisingbg_03.png',
				text: "招聘市集开启"
			}
		],
		logoList: [
			{
				name: "乐有家",
				text: "线上线下一体化E2E智能生态系统",
				path: 'static/img/logoimg/leyoujia.jpg',
				hoverShow: false
			},
			{
				name: "ZARA",
				text: "2021校招",
				path: 'static/img/logoimg/zara.png',
				hoverShow: false
			},
			{
				name: "小红书",
				text: "一个年轻人的生活方式平台",
				path: 'static/img/logoimg/xiaohongshu.jpg',
				hoverShow: false
			},
			{
				name: "罗氏制药",
				text: "罗氏是全球制药和诊断领域的领导者",
				path: 'static/img/logoimg/luoshi.png',
				hoverShow: false
			},
			{
				name: "搜狐",
				text: "中国领先的互联网媒体",
				path: 'static/img/logoimg/souhu.png',
				hoverShow: false
			},
			{
				name: "爱奇艺",
				text: "中国高品质视频娱乐服务提供者",
				path: 'static/img/logoimg/aiqiyi.jpg',
				hoverShow: false
			},
			{
				name: "源石财富",
				text: "国内顶尖的财富管理公司",
				path: 'static/img/logoimg/yuanshicaifu.png',
				hoverShow: false
			},
			{
				name: "科大讯飞",
				text: "中国的智能语音技术提供商",
				path: 'static/img/logoimg/kedaxunfei.jpg',
				hoverShow: false
			},
			{
				name: "快手",
				text: "国民短视频公司",
				path: 'static/img/logoimg/kuaishou.png',
				hoverShow: false
			}
		],
		lists: [
			{
				imgPath: 'static/img/l1.png'
			},
			{
				imgPath: 'static/img/zara.jpeg'
			},
			{
				imgPath: 'static/img/arti.jpeg'
			}
		],
		showBlock: [
			[
				{
					cName: "网易游戏",
					cType: "实习招聘",
					cImg: 'static/img/wangyiyouxi.jpg'
				},
				{
					cName: "学霸公社",
					cType: "校园招聘",
					cImg: 'static/img/xueba.jpg'
				},
				{
					cName: "学霸公社",
					cType: "校园招聘",
					cImg: 'static/img/xueba.jpg'
				}
			],
			[
				{
					cName: "辉瑞",
					cType: "实习招聘",
					cImg: 'static/img/ruihui.jpg'
				},
				{
					cName: "辉瑞",
					cType: "实习招聘",
					cImg: 'static/img/ruihui.jpg'
				},
				{
					cName: "慕格网络",
					cType: "校园招聘",
					cImg: 'static/img/moge.jpg'
				}
			]
		],
		items: [
			{
				name: "IT互联网",
				isSubShow: false,
				icon: "el-icon-mouse",
				clickIcon: "icon el-icon-arrow-left",
				index: "1",
				subItems: [
					{
						name: "软件"
					},
					{
						name: "Node.js"
					},
					{
						name: "运营"
					},
					{
						name: "硬件"
					},
					{
						name: "设计"
					},
					{
						name: "通信"
					},
					{
						name: "产品"
					}
				]
			},
			{
				name: "市场商务",
				isSubShow: false,
				icon: "el-icon-s-check",
				clickIcon: "icon el-icon-arrow-left",
				class: "icon",
				index: "2",
				subItems: [
					{
						name: "商务"
					},
					{
						name: "销售"
					},
					{
						name: "公关"
					},
					{
						name: "客服"
					},
					{
						name: "市场"
					}
				]
			},
			{
				name: "人事行政",
				isSubShow: false,
				icon: "el-icon-s-custom",
				clickIcon: "icon el-icon-arrow-left",
				class: "icon",
				index: "3",
				subItems: [
					{
						name: "人力资源"
					},
					{
						name: "猎头"
					},
					{
						name: "行政"
					}
				]
			},
			{
				name: "外语外贸",
				isSubShow: false,
				icon: "el-icon-s-comment",
				clickIcon: "icon el-icon-arrow-left",
				class: "icon",
				index: "4",
				subItems: [
					{
						name: "外语"
					},
					{
						name: "外贸"
					}
				]
			},
			{
				name: "教育咨询",
				isSubShow: false,
				icon: "el-icon-reading",
				clickIcon: "icon el-icon-arrow-left",
				class: "icon",
				index: "5",
				subItems: [
					{
						name: "教育"
					},
					{
						name: "咨询"
					}
				]
			},
			{
				name: "财经法务",
				isSubShow: false,
				icon: "el-icon-notebook-2",
				clickIcon: "icon el-icon-arrow-left",
				class: "icon",
				index: "6",
				subItems: [
					{
						name: "金融"
					},
					{
						name: "投资"
					},
					{
						name: "法务"
					},
					{
						name: "银行"
					}
				]
			},
			{
				name: "媒体设计",
				isSubShow: false,
				icon: "el-icon-brush",
				clickIcon: "icon el-icon-arrow-left",
				class: "icon",
				index: "7",
				subItems: [
					{
						name: "广告"
					},
					{
						name: "编辑"
					},
					{
						name: "设计"
					},
					{
						name: "媒体"
					}
				]
			},
			{
				name: "其他类型",
				isSubShow: false,
				icon: "el-icon-s-data",
				clickIcon: "icon el-icon-arrow-left",
				class: "icon",
				index: "8",
				subItems: [
					{
						name: "体育快消"
					},
					{
						name: "机械制造"
					},
					{
						name: "物流采购"
					},
					{
						name: "建筑房产"
					},
					{
						name: "生物医疗"
					},
					{
						name: "能源环保"
					},
					{
						name: "食品材料"
					},
					{
						name: "NGO公益"
					}
				]
			}
		],
		formLabelWidth: "80px",
		items2: [
			{
				title: "首页",
				index: "/index",
				class: "index1"
			},
			{
				title: "秋招日历",
				index: "/ftime",
				class: "index2"
			},
			{
				title: "大厂信息",
				index: "/factory",
				class: "index3"
			},
			{
				title: "校招",
				index: "/school",
				class: "index4"
			},
			{
				title: "offer直通车",
				index: "/offer",
				class: "index5"
			}
		]
	},
	created() {
		this.getJobList();
		this.isLogin();
		this.getid();
	},
	computed: {
		noMore() {
			return this.count >= 20
		},
		disabled() {
			return this.loading || this.noMore
		}
	},
	methods: {
		logout(){
			let logoutBtn = document.getElementById("log");
			logoutBtn.click();
		},
		load() {
			this.loading = true
			setTimeout(() => {
				this.count += 2
				this.loading = false
			}, 2000)
		},
		load() {
			this.count += 2
		},
		search(select, input) {
			if (select === '职位') {
				this.selectJobp(input);
			}
			if (this.select === '公司') {
				this.findByBuss(input);
			}
		},
		findByBuss(bname) {
			let data = new FormData();
			data.append("bname", bname);

			axios.post('/usert/findJob', data).then(resp => {
				sessionStorage.setItem("jobList", JSON.stringify(resp.data));
				sessionStorage.setItem("jobname", bname);
				window.location = "http://localhost:8082/usert/search?jobname=" + bname;
				console.log(JSON.parse(sessionStorage.getItem("jobList")));
			}).catch();
		},
		selectJobp(jobpart) {
			//console.log(jobpart);

			let data = new FormData();
			data.append("jobname", jobpart);

			axios.post('/usert/findJob', data).then(resp => {
				sessionStorage.setItem("jobList", JSON.stringify(resp.data));
				sessionStorage.setItem("jobname", jobpart);
				window.location = "http://localhost:8082/usert/search";
				console.log(JSON.parse(sessionStorage.getItem("jobList")));
			}).catch();
		},
		getResume() {
			axios.get('/usert/downloadresume').then(resp => {
				console.log(resp);
			}).catch();
		},
		getid() {
			axios.post('/usert/getloginid').then(resp => {
				this.id = "您好";
			}).catch();
		},
		isLogin() {
			axios.post('/usert/islogin').then(resp => {
				this.userisLogin = resp.data;
				this.hrisLogin = resp.data;
				console.log(this.userisLogin + '--' + this.hrisLogin);

			}).catch();
		},

		loadMore() {

		},
		tabHandler(tab) {
			if (tab.name === 'first') {
				this.getJobList();
			}
			if (tab.name === 'seconed') {
				this.getJobListByTime();
			}
		},
		getBussiness(bname) {
			sessionStorage.setItem("bname", bname);
			window.location.href = "http://localhost:8082/usert/b";
		},
		getJobDetails(jid) {
			sessionStorage.setItem("jid", jid);
			console.log(jid)
			window.location.href = "http://localhost:8082/usert/j";
		},
		getJobListByTime() {
			let _this = this;
			let data = new FormData();
			data.append('nextWant', _this.nextWant2);
			data.append('number', _this.number2);
			axios.post('/manager/getByTime', data)
				.then((response) => {
					//	console.log(response);
					let arr = response.data;
					for (let i = 0; i < arr.length; i++) {
						let obj = arr[i];
						let strWelfare = obj.welfare;
						let strJobTime = obj.jtime;
						let temp, temp2;
						//	console.log(strWelfare);
						if (temp !== 'undefined' && temp2 !== 'undefined') {
							temp = strWelfare.split(",");
							temp2 = strJobTime.split(",");
						}

						obj.welfare = temp;
						obj.jtime = temp2;
						arr.splice(i, 1, obj);
					}
					_this.jobListBytime = response.data;
				})
				.then((error) => {
					console.log(error);
				});
		},
		getJobList() {
			let _this = this;
			let data = new FormData();
			data.append('nextWant', this.nextWant);
			data.append('number', this.number);
			//	_this.jobList=[];
			axios.post('/manager', data
			)
				.then((response) => {
					//	console.log(response);
					let arr = response.data;
					for (let i = 0; i < arr.length; i++) {
						let obj = arr[i];
						let strWelfare = obj.welfare;
						let strJobTime = obj.jtime;
						let temp, temp2;
						//	console.log(strWelfare);
						if (temp !== 'undefined' && temp2 !== 'undefined') {
							temp = strWelfare.split(",");
							temp2 = strJobTime.split(",");
						}

						obj.welfare = temp;
						obj.jtime = temp2;
						arr.splice(i, 1, obj);
					}
					_this.jobList = response.data;
				})
				.then((error) => {
					console.log(error);
				});

		},
		hoverF(hoverShow, index) {
			this.logoList[index].hoverShow = !hoverShow;
		},
		isShow(index, item) {
			isClick = this.items[index].isSubShow = !item;
			isClick
				? (this.items[index].clickIcon = "icon el-icon-arrow-right")
				: (this.items[index].clickIcon = "icon el-icon-arrow-left");
		},
		format() {
			return "80%的求职者选择了我们";
		},
		click() {
			axios({
				method: "POST",
				url: "/count",
				data: {
					srollno: this.student.srollno,
					sname: this.student.srollno,
					spassword: this.student.spassword,
					sgender: this.student.sgender,
					sbatch: this.student.sbatch,
					count: this.count
				},
				success(response) {
					//   console.log(response);
				}
			});
		}
	},
});

